#include <iostream>
#include "sorting.h"
#include <vector>
#include <functional>
#include <ctime>
using namespace std;
int main(){
    vector<int> a(1000000);
    for (int i = 1; i <= 1000000; i++){
        a[i - 1] = i;
    }
    srand(unsigned(time(NULL)));
    int flag;
    flag=rand()%900000;
    for (int i = flag; i < flag+50000; i++){
        std::swap( a[ i ], a[ flag*2+99999-i ] );
    }
    
    vector<int> b(1000000);
    for (int i = 1; i <= 1000000; i++){
        b[i - 1] = i;
    }
    int flag2;
    flag2=rand()%683771;
    for (int i = flag2; i < flag2+158114; i++){
        std::swap( b[ i ], b[ flag2*2+316227-i ] );
    }

    vector<int> c(1000000);
    for (int i = 1; i <= 1000000; i++){
        c[i - 1] = 1000001-i;
    }
    int flag3;
    flag3=rand()%900000;
    for (int i = flag3; i < flag3+50000; i++){
        std::swap( c[ i ], c[ flag3*2+99999-i ] );
    }

    vector<int> d(1000000);
    for (int i = 1; i <= 1000000; i++){
        d[i - 1] = 1000001-i;
    }
    int flag4;
    flag4=rand()%683771;
    for (int i = flag4; i < flag4+158114; i++){
        std::swap( d[ i ], d[ flag4*2+316227-i ] );
    }
    
    // for (int i = 1; i <= 100000; i++){
    //     cout<< a[i - 1]<<" " ;
    // }
    //cout<< flag;
    /*for (int i = 1; i <= 2000; i++){
        cout<< a[i - 1]<<" " ;
    }*/
    clock_t start_time2=clock();
    heapsort(a);
    clock_t end_time2 = clock();
    cout<<"堆排序99%运行函数所需的时间" <<(double)(end_time2-start_time2)/CLOCKS_PER_SEC<<"秒" << endl;
    clock_t start_time1=clock();
    quicksort(a);
    clock_t end_time1 = clock();
    cout<<"快排序99%运行函数所需的时间" <<(double)(end_time1-start_time1)/CLOCKS_PER_SEC<<"秒" << endl;
    
    clock_t start_time3=clock();
    heapsort(b);
    clock_t end_time3 = clock();
    cout<<"堆排序90%运行函数所需的时间" <<(double)(end_time3-start_time3)/CLOCKS_PER_SEC<<"秒" << endl;
    clock_t start_time4=clock();
    quicksort(b);
    clock_t end_time4 = clock();
    cout<<"快排序90%运行函数所需的时间" <<(double)(end_time4-start_time4)/CLOCKS_PER_SEC<<"秒" << endl;

    clock_t start_time5=clock();
    heapsort(c);
    clock_t end_time5 = clock();
    cout<<"堆排序1%运行函数所需的时间" <<(double)(end_time5-start_time5)/CLOCKS_PER_SEC<<"秒" << endl;
    clock_t start_time6=clock();
    quicksort(c);
    clock_t end_time6 = clock();
    cout<<"快排序1%运行函数所需的时间" <<(double)(end_time6-start_time6)/CLOCKS_PER_SEC<<"秒" << endl;

    clock_t start_time7=clock();
    heapsort(d);
    clock_t end_time7 = clock();
    cout<<"堆排序10%运行函数所需的时间" <<(double)(end_time7-start_time7)/CLOCKS_PER_SEC<<"秒" << endl;
    clock_t start_time8=clock();
    quicksort(d);
    clock_t end_time8 = clock();
    cout<<"快排序10%运行函数所需的时间" <<(double)(end_time8-start_time8)/CLOCKS_PER_SEC<<"秒" << endl;
    return 0;
}